using Gadgeteer.Interfaces.Timed;
using System;

namespace Gadgeteer.Interfaces
{
    public interface ITimer
    {
        /// <summary>
        /// The behavior of this timer - whether to run once or run continuously.
        /// </summary>
        TimerBehavior Behavior { get; }

        /// <summary>
        /// Gets the interval that was assigned to this timer.
        /// </summary>
        TimeSpan Interval { get; set; }

        /// <summary>
        /// Gets a value that indicates whether this timer is running.
        /// </summary>
        bool IsRunning { get; }

        /// <summary>
        /// Restarts the timer
        /// </summary>
        void Restart();

        /// <summary>
        /// Starts the dispatch timer.
        /// </summary>
        /// <remarks>
        /// When you create a <see cref="ITimer"/> object, by default it is not started (that
        /// is, <see cref="IsRunning"/> is false). When you want to use the timer,
        /// you must first call method <see cref="Start"/>.
        /// </remarks>
        void Start();

        /// <summary>
        /// Stops the dispatch timer.
        /// </summary>
        void Stop();

        /// <summary>
        /// Raised after each timer interval specified by <see cref="Interval"/>.
        /// </summary>
        /// This event is raised when the timer is running, that is <see cref="IsRunning"/>
        /// is true.  Handle this event to perform periodic actions.
        /// <remarks>
        /// </remarks>
        event TickEventHandler Tick;
    }
}
